package com.epoint.mobileoa.personalized.epointcompany.ui.gzrz;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.CheckUserInfoModel;
import com.epoint.mobileoa.personalized.epointcompany.model.ShenHeInfoModel;

/**
 * @author liyc
 * @time 2012-8-27 下午6:25:16
 * @annotation 
 */
public class GetCanCheckUserListTask extends Task {

	/**
	 * @param con
	 * @param param
	 */
	public GetCanCheckUserListTask(SuperView con, Map<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		String rzdate = getParam().get("rzdate").toString();
		String userguid = getFP().getUserguid();
		
		String seamurl = generateURL("EpointGetCanCheckUserList",userguid,rzdate);
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(), bs);
	}

	public static List<CheckUserInfoModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<CheckUserInfoModel> plist = new ArrayList<CheckUserInfoModel>();
		for (int i = 0; i < focs.size(); i++) {
			CheckUserInfoModel mt = new CheckUserInfoModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("UserName") != null)
				mt.UserName = foc.elementText("UserName");
			if (foc.element("UserGuid") != null)
				mt.UserGuid = foc.elementText("UserGuid");
			if (foc.element("IsCheck") != null)
				mt.IsCheck = foc.elementText("IsCheck");
			if (foc.element("RZGuid") != null)
				mt.RZGuid = foc.elementText("RZGuid");
			if (foc.element("Flag") != null)
				mt.Flag = foc.elementText("Flag");
			if (foc.element("RZPSDate") != null)
				mt.RZPSDate = foc.elementText("RZPSDate");
			if (foc.element("IsReturn") != null)
				mt.IsReturn = foc.elementText("IsReturn");
			plist.add(mt);
		}
		return plist;
	}
}
